Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

core: Add support for QmlJs via tree-sitter-qmljs #46

Merged
merged 1 commit into from
Jun 24, 2024

Conversation

itzurabhi
Copy link
Contributor

Add QML TreeSitter support in build.

Part of #37

@itzurabhi itzurabhi force-pushed the QmlJS/initial-setup branch from 304cada to 8a32fb3 Compare June 21, 2024 08:49
Copy link
Member

@narnaud narnaud left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, just waiting for @LeonMatthesKDAB approval.
I'm surprised it's so easy, nice work ;)

@itzurabhi itzurabhi force-pushed the QmlJS/initial-setup branch from 8a32fb3 to 02ebae2 Compare June 24, 2024 06:54
Copy link
Collaborator

@LeonMatthesKDAB LeonMatthesKDAB left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some context on this PR:
@itzurabhi and I discussed for a while which tree-sitter grammar to use for QML.

The one from yuja stood out as the most complete, it is however still not "official" in any way shape or form.
But because there is no official Tree-sitter grammar, we have to rely on community bindings like this one.

The main reasons we chose this grammar:

Testing

The author tests their grammar against the examples in the Qt-declarative repository, which Qt also uses to test their own parser.
There are a few known failures, but it's not that many.

Inclusion of Typescript grammar

QML is made up of half-Javascript, half custom syntax.
This grammar uses the typescript grammar for the javascript part, on which we should be able to rely on going forward, as Typescript is of course very popular.
So in the worst case, we may have to find the right names for the QML part of the our tree-sitter queries, but can keep any conversions that we do in JS code, as they just rely on the typescript grammar.

So all in all, with these caveats in mind, I believe this is a good way forward on which we should be able to rely until (if at all) Qt provide their own tree-sitter grammar.

Also note that this PR doesn't yet add support for any QML documents, but that's a reasonably easy step to achieve later.

@narnaud narnaud merged commit 4da27e1 into KDAB:main Jun 24, 2024
5 checks passed
@itzurabhi itzurabhi deleted the QmlJS/initial-setup branch August 12, 2024 06:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants